package rest

import (
	"context"
	"fmt"

	"gitee.com/zatto/project/tree/master/vblog/api/apps/tag"
)

func (c *Client) CreateTag(ctx context.Context, in *tag.CreateTagRequest) (*tag.Tag, error) {
	ins := &tag.Tag{}
	err := c.c.Post("tags").Body(in).Do(ctx).Into(ins)
	if err != nil {
		return nil, err
	}
	return ins, err
}

func (c *Client) RemoveTag(ctx context.Context, in *tag.RemoveTagRequest) (*tag.TagSet, error) {
	set := &tag.TagSet{}
	err := c.c.Delete(fmt.Sprintf("tags/%d", in.BlogId)).Do(ctx).Into(set)
	if err != nil {
		return nil, err
	}
	return set, nil
}
